package flc.ast.utils;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.reflect.TypeToken;

import java.util.List;

import flc.ast.bean.MyDayBean;


public class AppSpUtils {
    private static final String SP_NAME = "appCollSp";
    private static final SPUtils sSpUtils = SPUtils.getInstance(SP_NAME);

    public static void savCommemorateList(List<MyDayBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_commemorate_list, json);
    }

    public static List<MyDayBean> getCommemorateList() {
        String json = sSpUtils.getString(Key.key_commemorate_list);
        return GsonUtils.fromJson(json, new TypeToken<List<MyDayBean>>() {
        }.getType());
    }

    public static void savCountdownList(List<MyDayBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_countdown_list, json);
    }

    public static List<MyDayBean> getCountdownList() {
        String json = sSpUtils.getString(Key.key_countdown_list);
        return GsonUtils.fromJson(json, new TypeToken<List<MyDayBean>>() {
        }.getType());
    }

    interface Key {
        String key_commemorate_list = "key_commemorate_list";
        String key_countdown_list = "key_countdown_list";
    }
}